package com.example.cadmin.controller;


import com.example.cadmin.mapper.SysParamsetMapper;
import com.example.cadmin.service.ElectronArchivesService;
import com.example.cadmin.utils.ResponseModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 电子档案 前端控制器
 * </p>
 *
 * @author  zzsoft 
 * @since 2025-10-23
 */
@Slf4j
@RestController
@RequestMapping("/electron/archives")
public class ElectronArchivesController {

    @Resource
    public ElectronArchivesService electronArchivesService;
    @Resource
    public SysParamsetMapper sysParamsetMapper;
    @Value("${SavePath.nginxPath}")
    private String nginxPath;

    /**
     * pdf 表格页面
     */
    @GetMapping("/table")
    public ModelAndView pdfTable(@RequestParam(value = "archivesId") String archivesId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("FileManage/electronArchivesTable");
        modelAndView.addObject("archivesId", archivesId);
        return modelAndView;
    }

    /**
     * pdf合并表格
     */
    @GetMapping("/table/list")
    public Map<String, Object> pdfList(@RequestParam(value = "archivesId") String archivesId,
                                       @RequestParam(value = "page") int page,
                                       @RequestParam(value = "limit") int limit) {
        return electronArchivesService.pdfList(archivesId, limit, page);
    }

    /**
     * 删除电子档案
     */
    @DeleteMapping("/delete/{id}")
    @ResponseBody
    public ResponseModel deleteElectron(@PathVariable("id") String id) {
        return electronArchivesService.deleteElectron(id);
    }

}
